package com.hui.dbmigrator.entity;

import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

import javax.validation.Valid;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotEmpty;
import java.util.List;

@Data
public class TableDefinition {
    @NotBlank
    private String name;

    @Valid
    @NotEmpty
    private List<ColumnDefinition> columns;

    private String comment;
    private String engine; // For MySQL
    private String charset;

    @Data
    public static class ColumnDefinition {
        @NotBlank
        private String name;

        @NotBlank
        private String type;

        private Integer length;
        private Integer precision;
        private Integer scale;
        private boolean nullable;
        private String defaultValue;
        private String comment;
        private boolean primaryKey;
        private boolean autoIncrement;
    }
}
